package com.yequan.leetcode.bit.isPalindrome_9;

/**
 * @author yequan
 * @date 2022/02/22 23:24
 **/
public class IsPalindrome {

    public boolean isPalindrome1(int x) {
        if (x < 0) {
            return false;
        }
        if (x > 0 && x % 10 == 0) {
            return false;
        }
        int currentNum = 0;
        int num = x;
        while (num != 0) {
            currentNum = currentNum * 10 + num % 10;
            num /= 10;
        }
        return currentNum == x;
    }

    public boolean isPalindrome2(int x) {
        if (x < 0) {
            return false;
        }
        if (x > 0 && x % 10 == 0) {
            return false;
        }
        int num = x;
        int currentNum = 0;
        while (num != 0) {
            currentNum = currentNum * 10 + num % 10;
            num /= 10;
        }
        return x == currentNum;
    }

    public boolean isPalindrome3(int x) {
        if (x < 0) {
            return false;
        }
        if (x > 0 && x % 10 == 0) {
            return false;
        }
        int currentNum = 0, num = x;
        while (num != 0) {
            currentNum = currentNum * 10 + num % 10;
            num /= 10;
        }
        return x == currentNum;
    }

}
